/*
** basics2.c for mysh in /home/nadali_t//local/svn/tek2ed/minishell1
** 
** Made by thomas nadalie
** Login   <nadali_t@epitech.net>
** 
** Started on  Thu Nov  8 12:22:42 2012 thomas nadalie
** Last update Thu Nov  8 12:22:44 2012 thomas nadalie
*/

#include	<stdlib.h>
#include	"my.h"

char		*my_concat(char *str, char *str2)
{
  char		*str3;
  int		i;
  int		j;
  int		k;
  
  i = 0;
  j = 0;
  k = 0;
  if ((str3 = malloc((my_strlen(str) + my_strlen(str2) + 1)
                      * sizeof(*str3))) == NULL)
    return (NULL);
  while (str[i])
    str3[k++] = str[i++];
  while (str2[j] && str2[j] != '\n')
    str3[k++] = str2[j++];
  str3[k] = '\0';
  return (str3);
}

int		my_tablen(char **tab)
{
  int		i;

  i = 0;
  while (tab[i])
    i++;
  return (i);
}

int		my_strcmp(char *s1, char *s2)
{
  int		i;
  int		j;

  i = 0;
  j = 0;
  while (s1[i] && s2[i])
    {
      if (s1[i] == s2[i])
	j++;
      i++;
    }
  return (i - j);
}

char		*my_strdup(char *src)
{
  char		*dest;
  int		i;

  i = 0;
  if ((dest = malloc((my_strlen(src) + 1) * sizeof(*dest))) == NULL)
    return (NULL);
  my_bzero(dest, my_strlen(src));
  while (src[i])
    {
      dest[i] = src[i];
      i++;
    }
  dest[i] = '\0';
  return (dest);
}

void		cmd_error(char **tab)
{
  my_putstr(tab[0]);
  my_putstr(" : command not found\n");
  exit(0);
}
